<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" media="screen" type="text/css" href="__THEMES__/style/layout.css" />
		<script type="text/javascript" src="__JS__/jQuery/jquery.js"></script>
		<script type="text/javascript" src="__JS__/jQuery/plugin/alertbox.js"></script>
		<include file="Public:js_editor" />
		<include file="Public:js_swfupload" />
		<script type="text/javascript">
			var editor;
			KindEditor.ready(function(K){
				editor = K.create("#content",{
					width : "80%",
					items : [
						'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
						'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
						'insertunorderedlist', '|', 'emoticons', 'link']
				});
			});
        	
            $(function(){
                
                picslist();
                
                $('form').submit(function(){
					if ( $.trim( $( 'input[name="title"]' ).val() ) == '' ){
						setInputStyle( 'input[name="title"]' );
						setAlertBox('标题不能为空！', 2);
						return false;
					}
				});
				removeInputStyle('.input_text');
				
				//删除单个图片
				$('.del_action').click(function(){
					var url = $(this).attr('href');
					var thisDom = $(this).parent().parent();
					if (confirm('确定删除？')){
						$.ajax({
							url : url,
							type : 'GET',
							dataType : "json",
							success : function(m){
								if(m.status == 0){
									alert('删除失败');
									return false;
								}else{
									thisDom.remove();
								}
							},
							cache : false
						});
					}
					return false;
				});
				
				// 设置已有图片为缩略图
				$('.set_thumb').click(function(){
					var file = $(this).attr('rel');
					$("#thumb").val(file);
					$("#thumb_pic_tr").show();
					$("#thumb_pic").attr("src","__PUBLIC__/{:C('DIR_UPLOAD_PATH')}/"+file);
				});
				
            });
		</script>
		<link rel="stylesheet" type="text/css" href="__THEMES__/style/swfupload.css" />
		<style type="text/css">
			table td		{ border:0; padding:7px 5px; }
			.edit_picture_list		{ margin:0; padding:0; list-style:none; }
			.edit_picture_list li	{ float:left; margin-right:20px; margin-bottom:20px; }
			.swfupload {
				position: absolute;
				z-index: 888;
				width: 70px;
				height:27px;
			}
		</style>
	</head>
	<body>
		<div id="preview" style="position:absolute; display:none; " class="showpic"> <img name="pic_a1" id="pic_a1"></div>
		<include file="Public:position" />
		
		<div class="a_table">

	    	<form action="__URL__/update" method="post">
	    	<input type="hidden" name="id" value="{$vo.id}" />
			<table width="100%" style="border: 1px solid #eee; background: #f9f9f9;">
				<tr>
					<td align="right"</td>
					<td align="left"></td>
				</tr>
				<tr>
					<td align="right" width="100">标题</td>
					<td align="left"><input type="text" name="title" class="input_text w480" value="{$vo.title}" /></td>
				</tr>
				<tr>
					<td align="right">分类</td>
					<td align="left">
						<select name="cid" class="input_text" style="width:auto;">
							<option value="0">默认相册</option>
							{$option}
						</select>
					</td>
				</tr>
				<tr>
					<td align="right">属性</td>
					<td align="left">
						<input type="checkbox" name="set_top" value="1"<php>if($vo['set_top'] == 1){</php> checked="checked"<php>}</php> /> 置顶 &nbsp;&nbsp;
						<input type="checkbox" name="recommend" value="1"<php>if($vo['recommend'] == 1){</php> checked="checked"<php>}</php> /> 推荐 &nbsp;&nbsp;
					</td>
				</tr>
				<tr>
					<td align="right">状态</td>
					<td align="left">
						<input type="radio" name="status" value="1"<php>if($vo['status'] == 1){</php> checked="checked"<php>}</php> /> 显示 &nbsp;&nbsp;
						<input type="radio" name="status" value="0"<php>if($vo['status'] == 0){</php> checked="checked"<php>}</php> /> 隐藏 &nbsp;&nbsp;
					</td>
				</tr>
				<tr>
					<td align="right">标签</td>
					<td align="left"><input type="text" name="tags" class="input_text w480" value="{$vo.tags}" /> 多个用空格分割</td>
				</tr>
				<tr>
					<td align="right">缩略图</td>
					<td align="left">
						<input type="text" name="thumb" id="thumb" value="{$vo.thumb}" class="input_text w480" />
					</td>
				</tr>
				<?php
					if (!empty($vo['thumb']) && $vo['thumb'] != 'no_thumb.jpg'){
				?>
				<tr id="thumb_pic_tr">
					<td align="right">&nbsp;</td>
					<td align="left"><img src="__PUBLIC__/{:C('DIR_UPLOAD_PATH')}/{$vo.thumb}" id="thumb_pic" /></td>
				</tr>
				<?php
					}else{
				?>
				<tr id="thumb_pic_tr">
					<td align="right">&nbsp;</td>
					<td align="left"><img src="__PUBLIC__/images/no_thumb.jpg" id="thumb_pic" /></td>
				</tr>
				<?php
					}
					$p_model = M('Picture');
					$p_list = $p_model->where("cid='".$vo['id']."'")->select();
					if (!empty($p_list)){
				?>
				<tr>
					<td align="right">已有图片</td>
					<td align="left">
						<ul class="edit_picture_list">
						<?php
							foreach($p_list as $key=>$val){
						?>
							<li>
								<a href="__PUBLIC__/{:C('DIR_UPLOAD_PATH')}/{$val['folder']}/{$val['file']}" target="_blank"><img border="0" src="__PUBLIC__/{:C('DIR_UPLOAD_PATH')}/{$val['folder']}/thumb_{$val['file']}" /></a>
								<p class="del_picture">&nbsp;&nbsp;
									<a href="{:U('delpicture',array('item'=>$val['id']))}" class="del_action">删除</a> &nbsp;
									<a href="javascript:;" class="set_thumb" rel="{$val['folder']}/thumb_{$val['file']}">设置缩略图</a>
								</p>
							</li>
						<?php
							}
						?>
						</ul>
					</td>
				</tr>
				<?php
					}
				?>
				<tr>
					<td align="right">追加图片</td>
					<td align="left">
						<div style="position: relative;">
						<span id="spanButtonPlaceholder"></span>
						<input type="button" class="submit" id="btnUpload" value="批量选择" />
						<input type="button" disabled="disabled" class="submit" id="btnCancel" value="  中止上传  " />
						</div>
					</td>
				</tr>
				<tr>
					<td align="right">上传进度</td>
					<td align="left">
						<div id="divLoadingContent" class="content" style="display: none;">上传组件正在加载中...</div>
						<div id="divLongLoading" class="content" style="display: none;">上传组件加载超时!请确保浏览器支持FLASH 10!</div>
						<div id="divAlternateContent" class="content" style="display: none;">上传组件加载失败!请确保浏览器支持FLASH 10!</div>  
						<div class="fieldset flash" id="fsUploadProgress"></div>
						<p id="divStatus">提示: 可以按 Ctrl 或 Shift 键多选.</p>
					</td>
				</tr>
				<tr>
					<td align="right">追加图片列表</td>
					<td align="left">
						<div id="pics_upload_list"><img src="__THEMES__/images/loading.gif" align="absmiddle"> 列表加载中...</div>
					</td>
				</tr>
				<tr>
					<td align="right">组图介绍</td>
					<td align="left"><textarea name="content" id="content" style="width: 100%; height:260px;">{$vo.content}</textarea></td>
				</tr>
				<tr>
					<td align="right"></td>
					<td align="left"><input type="submit" class="submit" value="提交表单" /></td>
				</tr>
				<tr>
					<td align="right"</td>
					<td align="left"></td>
				</tr>
			</table>
			</form>
        </div>
	</body>
</html>